/**
 * @author songxinfeng
 * @date 2024-03-21
 */

import request from '@/utils/request'

export interface Department {
  id: number
  name: string
  fullName: string
  parentId?: number
  level: number
  sort: number
  createAt: string
  updateAt: string
}

interface DepartmentUser {
  id: number
  name: string
  username: string
}

export function getAllDepartments() {
  return request.get<Department[]>('/api/departments')
}

export function getDepartmentUsers(departmentId: number): Promise<{ data: DepartmentUser[] }> {
  return request({
    url: `/api/departments/${departmentId}/users`,
    method: 'get',
  })
}
